const path = require('path');
const SkeletonWebpackPlugin = require('vue-skeleton-webpack-plugin');

function resolve(dir) {
    return path.join(__dirname, dir)
}
module.exports = {
    lintOnSave: true,
    devServer: {
        host: '0.0.0.0',
        port: 8080
    },
    publicPath: '/',
    configureWebpack: (config) => {
        // vue骨架屏插件配置
        config.plugins.push(new SkeletonWebpackPlugin({
            webpackConfig: {
                entry: {
                    app: path.join(__dirname, './src/config/skeleton.js'),
                },
            },
            router: {
                mode: 'history',
                routes: [
                    {
                        path: '/',
                        skeletonId: 'skeleton1'
                    },
                    {
                        path: '/home',
                        skeletonId: 'skeleton2'
                    },
                ]
            },
            minimize: true,
            quiet: true,
        }))
    },
    css: {
        loaderOptions: {
            postcss: {
                // exclude: ['/node_modules/']
            }
        },
        // 是否使用css分离插件 ExtractTextPlugin
        extract: true,
        // 开启 CSS source maps?
        sourceMap: false,
        // 启用 CSS modules for all css / pre-processor files.
        modules: false
    },
    chainWebpack: (config) => {
        config.resolve.alias
            .set('@$', resolve('src'))
            .set('assets', resolve('src/assets'))
            .set('components', resolve('src/components'))
            .set('layout', resolve('src/layout'))
            .set('base', resolve('src/base'))
            .set('static', resolve('src/static'))
    }
}